<?php 
namespace Admin\Controller;
use Think\Controller;

//---------------
//Author:Hua
//--------------

class LoginController extends Controller{
	/*分配登陆模板*/
	public function login(){
		$this->display();
	}
	/*用Ajax进行登陆验证*/
	public function aja(){
		$arr = array();
		$yzm=$_POST['yzm'];
		$name = htmlspecialchars($_POST['name']);
		$pass = $_POST['pass'];
		$Verify = new \Think\Verify();
		$result = $Verify->check($yzm);
		if(!$result){
			$arr[3] = a;
		}else{
			$log = new \Think\Model('User');
			$where = array('name'=>$name);
			if(!$user = $log->where($where)->select()){
				$arr[1] = b;
			}else{
				if($user[0]['pass'] != md5($pass)){
					$arr[2] = c;
				}else{
					$_SESSION['admin'] = $user;
				}
			}
		}
		$this->ajaxReturn($arr);	
	}

	/*注销后台用户*/
	public function loginout(){
		unset($_SESSION['admin']);
		$this->display('login');
	}

	/*验证码*/
	public function yzm(){
		$config =    array(  
		  'fontSize'    =>    17,    // 验证码字体大小   
		  'length'      =>    4,     // 验证码位数    
		  'useNoise'    =>    false, // 关闭验证码杂点
		  
		 );
		$Verify = new \Think\Verify($config);
		$Verify->entry();
	}


}


?>